package cool.taomu.box.tomcat.config

import com.google.inject.Provider
import java.io.IOException
import javax.servlet.Servlet
import javax.servlet.ServletException
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import org.slf4j.LoggerFactory

class TomcatDefaultHttpServletProvider implements Provider<Servlet> {
	val static LOG = LoggerFactory.getLogger(TomcatDefaultHttpServletProvider);

	override get() {
		LOG.info("加载 http servlet")
		return new HttpServlet() {
			override void service(HttpServletRequest request,
				HttpServletResponse response) throws ServletException, IOException {
				var name = request.requestURI
				LOG.info("请求链接:{}", name);
				try(var w = response.writer) {
					w.write("Hello Taomu box");
					w.flush
				}
			}
		}
	}

}
